﻿using System;

namespace Byleist.Caching
{
    public class DelegateCacheValueRetrievingPolicy<T> : ICacheValueRetrievingPolicy<T>
    {
        private readonly Func<T> getLatestValue;

        public DelegateCacheValueRetrievingPolicy(Func<T> getLatestValue)
        {
            if (getLatestValue == null) throw new ArgumentNullException("getLatestValue");
            this.getLatestValue = getLatestValue;
        }

        public T GetValue()
        {          
            return this.getLatestValue();
        }
    }
}